<template>
    <div style="width:100%;height:100%;overflow:hidden">
        <weui-cell :list="cell_0_list">
        </weui-cell>
        <div style="margin:15px">
            <weui-button type="primary" @on-click="on_logout_click">登出</weui-button>
        </div>
    </div>
</template>

<script>
    import WeuiCell from '../vue2componentSet/src/components/WeuiCell'
    import WeuiButton from '../vue2componentSet/src/components/WeuiButton'
    import global from '../lib/global'
    import axios from 'axios'

    export default {
        components: {
            WeuiCell,
            WeuiButton
        },
        data() {
            return {
                cell_0_list: [{
                    value: '购物返现',
                    link: '#/returnRecord'
                }, {
                    value: '我的订单',
                    link: '#/bill'
                }, {
                    value: '设置密码',
                    link: '#/setPassword'
                }, {
                    value: '设置返现方式',
                    link: '#/setReturnWay'
                }]
            }
        },
        mounted() {
            this.$store.commit('set_title', '用户菜单')

            if (!this.$store.state.customer) {
                this.$router.goback()
                return
            }

            if (this.$store.state.customer.returnWay == 'wechat')
                this.$set(this.cell_0_list[3], 'desc', '微信红包')
            else if (this.$store.state.customer.returnWay == 'alipay')
                this.$set(this.cell_0_list[3], 'desc', '支付宝')

            if (this.$store.state.customer.isPromoter) {
                this.cell_0_list.push({
                    value: '分享佣金',
                    link: '#/promotee'
                })
            }

            if (this.$store.state.customer.wechatQrcode) {
                this.cell_0_list.push({
                    value: '我的推广二维码',
                    link: '#/wechatQrcode'
                })
                this.cell_0_list.push({
                    value: '拉新活动（4至6月）',
                    link: '#/activity0'
                })
            }

            if (this.$store.state.admin) {
                this.cell_0_list.push({
                    value: '管理员菜单',
                    link: '#/adminMenu'
                })
            }

            axios.post(global.server + 'getMoney.do', {
            }).then(result => {
                var obj = result.data
                if (obj.result == 1) {
                    this.$set(this.cell_0_list[0], 'desc', obj.returnMoney)
                    if (this.$store.state.customer.isPromoter) {
                        this.$set(this.cell_0_list[4], 'desc', '已返' + obj.returnPromoterMoney + '(待返' + obj.willReturnPromoterMoney + ')')
                    }
                }
            })
        },
        methods: {
            on_logout_click() {
                axios.post(global.server + 'customerLogout.do', {}).then(result => {
                    this.$store.commit('customer_login', null)
                    this.$router.goback()
                })
            }
        },
    }
</script>
